package yl.hs.bmipfull.controllers.report;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yl.hs.bmipfull.controllers.ControllerBase;
import yl.hs.bmipfull.service.report.IMonthlyReportService;
import yl.hs.bmipfull.service.report.IShipSettleMonthlyReportService;
import yl.hs.bmipfull.viewmodels.PageQuery;
import yl.hs.bmipfull.viewmodels.WebResult;

/**
 * 作用: 月报报表  <br/>
 * 创建时间: 2022-03-04 <br/>
 * 生产统计web接口
 * @author 谢东
 */
@Api(value = "月报报表web接口",tags = "报表中心-月报报表")
@RestController
@RequestMapping(value = "/api/MonthlyReport")
public class MonthlyReportController extends ControllerBase {
    @Autowired
    IMonthlyReportService monthlyReportService;

    @Autowired
    IShipSettleMonthlyReportService shipSettleReportService;

    @ApiOperation(value = "分页查询产品销售月报表接口", notes = "分页查询产品销售月报表接口")
    @RequestMapping(value = "ProductSales/{rowNum}/{page}/{productCateSn}",method = RequestMethod.POST)
    public WebResult getProductSalesMonthlyReport(@ApiParam(value = "查询条件") @RequestBody PageQuery pageQuery,
                                                  @ApiParam(value = "页码") @PathVariable int page,
                                                  @ApiParam(value = "每页条数") @PathVariable int rowNum,
                                                  @ApiParam(value = "产品编号") @PathVariable(required = false) String productCateSn){
        return  success("查询成功",monthlyReportService.getProductSalesMonthlyReport(pageQuery, productCateSn,rowNum,page));
    }
    @ApiOperation(value = "分页查询原材采购月报表接口", notes = "分页查询原材采购月报表接口")
    @RequestMapping(value = "MonthlyRaw/{rowNum}/{page}/{productSn}",method = RequestMethod.POST)
    public WebResult getMonthlyRawReportPageQuery(@ApiParam(value = "查询条件") @RequestBody PageQuery pageQuery,
                                                  @ApiParam(value = "页码") @PathVariable int page,
                                                  @ApiParam(value = "每页条数") @PathVariable int rowNum,
                                                  @ApiParam(value = "每页条数") @PathVariable String productSn){
        return  success("查询成功",monthlyReportService.getMonthlyRawReportPageQuery(pageQuery,rowNum,page,productSn));
    }
    @ApiOperation(value = "查询原材成本分析", notes = "查询原材成本分析")
    @RequestMapping(value = "RawCostAnalysis/{productSn}",method = RequestMethod.POST)
    public WebResult getRawCostAnalysis(@ApiParam(value = "查询条件") @RequestBody PageQuery pageQuery,
                                                  @ApiParam(value = "每页条数") @PathVariable String productSn){
        return  success("查询成功",monthlyReportService.getRawCostAnalysis(pageQuery,productSn));
    }
    @ApiOperation(value = "分页查询销售结算月报表接口", notes = "分页查询销售结算月报表")
    @RequestMapping(path = {"/ship-settle/{rowNum}/{page}"}, method = RequestMethod.POST)
    public WebResult queryShipSettleMonthlyReport(@RequestBody PageQuery query,  @PathVariable int rowNum, @PathVariable(required = false) int page){
        return success("ok",shipSettleReportService.queryPage(query, page, rowNum));
    }

    @ApiOperation(value = "查询销售结算单时间分组", notes = "查询销售结算单时间分组")
    @RequestMapping(path = {"/ship-settle/time-group"}, method = RequestMethod.GET)
    public WebResult queryShipSettleGroupTime(){
        return success("ok",shipSettleReportService.getSetTimeGroup());
    }
}
